#ifndef PATH_APP
#define PATH_APP

#include "wolf.hpp"
#include <sstream>
#include "messages.hpp"
#include "algorithms.hpp"

using namespace wolf;
using namespace std;
/**
 * @brief An application that provides configuration to app
 *
 *
 * @since 2010-07-25-16.15
 **/
class PathApp: public ConsoleApp
{
public:
    int run( const vector<string> &params )
    {
        bool running = true;
        while( running )
        {
            putChar('>');
            stringstream input( getLine() );
            string command;
            input >> command;
            if( command == "exit" )
            {
                sendMessage( new ConsoleMessage( MESS_EXIT ) );
                running = false;
            }
            else if ( command == "edit" )
            {
                sendMessage( new ConsoleMessage( MESS_EDIT ) );
            }
            else if ( command == "run" )
            {
                string param;
                input >> param;
                if(param == "")
                {
                    putString("You must select an algorithm to run\n");
                }
                else
                {
                    PathAlg *alg = newAlg(param);
                    if(!alg)
                    {
                        putString("Invalid algorithm\n");
                        continue;
                    }
                    sendMessage( new ConsoleMessage( MESS_RUN, alg ) );
                }
            }
            else if ( command == "pencil")
            {
                sendMessage( new ConsoleMessage( MESS_PENCIL ) );
            }
            else if ( command == "eraser")
            {
                sendMessage( new ConsoleMessage( MESS_ERASER ) );
            }
            else if ( command == "source")
            {
                sendMessage( new ConsoleMessage( MESS_SOURCE ) );
            }
            else if ( command == "destiny")
            {
                sendMessage( new ConsoleMessage( MESS_DESTINY ) );
            }
            else if ( command == "clear" )
            {
                clear();
            }
            else
            {
                putString("Not recognized command!\n");
            }
            //
        }
        return 0;
    }
private:

};


#endif // PATH_APP

